<?php
namespace App\Http\Forms;

use Kris\LaravelFormBuilder\Form;

class PackageLibForm extends Form
{
    public function buildForm()
    {
        $this
//            ->add('package_attr_id', 'select', [
//                'label' => "产品类型",
//                'rules' => 'required|integer',
//                'choices' => $this->getData('attr'),
//            ])
            ->add('value', 'text', [
                'label' => '产品',
                'rules' => "required|string",
            ])
            
            ->add('price', 'text', [
                'attr' => ['class' => "form-control lib-price"],
                'label' => '价格',
                'rules' => "required|numeric|min:0|max:9999999",
                'type' => 'cover',
            ])
            ->add('discount', 'text', [
                'attr' => ['class' => "form-control lib-discount"],
                'label' => "折扣(%)",
                'rules' => "nullable|integer|min:0|max:9999999",
            ])
            ->add('sort', 'text', [
                'label' => '排序权重',
                'rules' => "required|integer",
                'default_value' => 0,
            ])

            ->add('cover', 'image', [
                'label' => '展示图',
                'rules' => "required|string",
                'type' => 'cover',
                'help_block' => [
                    'text' => "建议尺寸600*600",
                ]
            ])
            ->add('description', 'textarea', [
                'attr' => ['id' => 'editor'],
                'label' => "详情",
                'rules' => 'required|string',
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
